package com.isoftstone.bank.controller.base;



import com.isoftstone.common.base.SessionManager;
import com.isoftstone.util.PageData;
import org.apache.shiro.session.Session;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 类名称：获取上传文件进度controller
 *
 * @author：guoX
 * @date: 2016/6/6
 */
@Controller
public class GetFileProcessController extends  BaseController{
    private Log logger = LogFactory.getLog(this.getClass());


    @RequestMapping(value="/getFileProcess")
    @ResponseBody
    public Map<String,Object> getFileProcess(){
        Map<String,Object> map = new HashMap<String,Object>();
        PageData pd = this.getPageData();
        Session session = SessionManager.getSession();
        logger.info("GetFileProcessController#getFileProcess start");
        String fileUploadPercent = (String)session.getAttribute("upload_ps");
        //Progress status = (Progress) session.getAttribute("upload_ps");
        try {
            if(fileUploadPercent == null || "".equals(fileUploadPercent)){
                map.put("upload_ps","0%");
            }else{
                map.put("upload_ps",fileUploadPercent);
            }
        } catch(Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage(), e);
        }
        logger.info("GetFileProcessController#getFileProcess end");
        return map;
    }
}
